package org.oimwrapper.connectors.common;

import com.thortech.xl.util.config.*;
import java.util.*;

import org.oimwrapper.connectors.*;

/**
 * Prints the current settings for the OIM database.<p>
 *
 * This task expects the following parameters, in addition to the standard
 * parameters in the {@link OIMTaskBase} class.
 */
public class OIMPrintDbSettings extends OIMTaskBase {
    
	/**
	 * Default constructor.
	 */
	public OIMPrintDbSettings() {
		super("OIMWRAPPER.TASK");
	}

	/**
	 * This method is called by the scheduler to execute the task instance.
	 */
	public void execute() {
		try {
			ConfigurationClient client = ConfigurationClient.getConfigurationClient();
			Properties properties = client.getComplexSetting("DirectDB").getAllSettings();
			logger.warn("-------------------------------------------------------------------");
			logger.warn("   Driver = " + properties.getProperty("driver"));
			logger.warn("      URL = " + properties.getProperty("url"));
			logger.warn(" Username = " + properties.getProperty("username"));
			logger.warn(" Password = " + properties.getProperty("password"));
			logger.warn("-------------------------------------------------------------------");
		} catch (Exception e) {
			OIMExceptionHandler.handleException(logger, e, getClass());
		}
	}

	/**
	 * This method is called by the scheduler to stop a running task instance.
	 * 
	 * @return <code>true</code>
	 */
	public boolean stop() {
		return true;
	}
}